import java.util.Scanner;

/**
 *   https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded?tpId=37&tqId=21296&ru=/exam/oj
 *
 *   根据输入的日期，计算是这一年的第几天。
 * 保证年份为4位数且日期合法。
 * 进阶：时间复杂度：O(n)\O(n) ，空间复杂度：O(1)\O(1)
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();
        int month = in.nextInt();
        int data = in.nextInt();

        int count = 1;
        int result = 0;
        while(count < month) {
            if(count == 1 || count == 3 || count == 5 ||
                    count == 7 || count == 8 || count == 10 || count == 12) {
                result += 31;
            } else if(count == 2) {
                result += 28;
                // 判断是不是闰年.
                if(isLeadYear(year))
                    result += 1;
            } else {
                result += 30;
            }
            ++count;
        }

        result += data;
        System.out.println(result);

    }

    private static boolean isLeadYear(int year) {
        return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
    }
}